package com.ketangpai.admin.controller;

import com.ketangpai.admin.entity.Course;
import com.ketangpai.admin.entity.HomeworkGrade;
import com.ketangpai.admin.entity.TestGrade;
import com.ketangpai.admin.service.ClassDetailService;
import com.ketangpai.admin.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/classDetail/grade")
@Api(tags = "课程详情")
public class ClassDetailController {

    @Resource
    private ClassDetailService classDetailService;

    @ApiOperation(value = "作业成绩")
    @PostMapping("/homework")
    public JsonResult<?> getHomeworkGrade(Integer courseId,Integer userId) {
        HomeworkGrade[] homeworkGrade= classDetailService.getHomeworkGrade(courseId,userId);
        return JsonResult.success(homeworkGrade);
    }

    @ApiOperation(value = "课程信息")
    @PostMapping("/information")
    public JsonResult<?> getCourseInformation(Integer courseId) {
        Course course= classDetailService.getCourseInformation(courseId);
        System.out.println(course);
        System.out.println(courseId);
        return JsonResult.success(course);
    }

    @ApiOperation(value = "测试成绩")
    @PostMapping("/test")
    public JsonResult<?> getTestGrade(Integer courseId,Integer userId) {
        TestGrade[] testGrade= classDetailService.getTestGrade(courseId,userId);
        return JsonResult.success(testGrade);
    }
}
